package com.richie696.bank.account.model;

import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;

public class AccountRequestModel {

    private String fromCardNo;

    private String toCardNo;

    private String money;

    public AccountRequestModel() {
    }

    public AccountRequestModel(String fromCardNo, String toCardNo, String money) {
        this.fromCardNo = fromCardNo;
        this.toCardNo = toCardNo;
        this.money = money;
    }

    public String getFromCardNo() {
        return fromCardNo;
    }

    public void setFromCardNo(String fromCardNo) {
        this.fromCardNo = fromCardNo;
    }

    public String getToCardNo() {
        return toCardNo;
    }

    public void setToCardNo(String toCardNo) {
        this.toCardNo = toCardNo;
    }

    public String getMoney() {
        return money;
    }

    public void setMoney(String money) {
        this.money = money;
    }

    public BigDecimal getMoneyNumeric() {
        if (isInvalid()) {
            return BigDecimal.ZERO;
        }
        return BigDecimal.valueOf(Long.parseLong(money));
    }

    public boolean isInvalid() {
        return StringUtils.isBlank(fromCardNo) ||
                StringUtils.isBlank(toCardNo) ||
                !StringUtils.isNumeric(money);
    }
}
